import type * as Dev from "./types"
import { request } from "@/http/axios"

const baseURL = import.meta.env.VITE_TRAIN_API

/** 生成代码 */
// export function generateAgent(data: Dev.GenerateAgentData) {
//   return request<ApiResponseData<{ agent_temp_file_id: string }>>({
//     url: `/toksim/dev_assistant/agent_temp/create`,
//     method: 'post',
//     data,
//   })
// }
export function generateAgent(associate_id: string, data: Dev.GenerateAgentData) {
  return request<ApiResponseData<{ agent_temp_file_id: string }>>({
    baseURL,
    url: `/toksim/dev_assistant/agent/content/create`,
    method: "post",
    data
  })
}

/** 获取文件结构 */
export function getDirCatalog(data: {
  dir_id: string
  agent_id: string
  agent_flag: string
}) {
  return request<Dev.CatalogResponseData>({
    baseURL,
    url: `/toksim/dev_assistant/agent/dir/get`,
    method: "post",
    data
  })
}

/** 获取文件内容 */
export function getFileContent(data: {
  dir_id: string
  agent_flag: boolean
}) {
  return request({
    baseURL,
    url: `/toksim/dev_assistant/agent/content/get`,
    method: "post",
    data
  })
}

/** 更新智能体模板文件内容 */
export function updateAgentFile(data: FormData) {
  return request<ApiResponseData<undefined>>({
    baseURL,
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/dev_assistant/agent_temp/update",
    method: "post",
    data
  })
}

/** 更新智能体模板文件内容 */
export function saveAgentFile(data: FormData) {
  return request<ApiResponseData<undefined>>({
    baseURL,
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/dev_assistant/agent/content/save",
    method: "post",
    data
  })
}

/** 生成场景 */
export function createGame(id: string, game_name: string) {
  return request({
    baseURL,
    url: `/toksim/dev_assistant/game_temp/create`,
    method: "post",
    data: {
      agent_temp_file_id: id,
      game_name
    }
  })
}
